<template>
	<view v-if="pageShow">
		<view class="mainpadding" style="padding-bottom: 150rpx;">
			<view class="flexbetween">
				<view class="flexleft">
					<view class="margin_right lableradius waisong" v-if="orderInfo.type==0">外送</view>
					<view class="margin_right lableradius ziqu" v-if="orderInfo.type==1">自取</view>
					<view class="margin_right lableradius neiyong" v-if="orderInfo.type==2">内用</view>
					<view class="hei_text titletext bold" v-if="orderInfo.status==0">待支付</view>
					<view class="hei_text titletext bold" v-if="orderInfo.status==1">待接單</view>
					<view class="hei_text titletext bold" v-if="orderInfo.status==2">製作中</view>
					<!-- <view class="hei_text titletext bold" v-if="orderInfo.status==3">待取货</view> -->
					<view class="hei_text titletext bold" v-if="orderInfo.status==6">等待騎手接單</view>
					<view class="hei_text titletext bold" v-if="orderInfo.status==7 && orderInfo.ps_type==1">商家自送配送中
					</view>
					<view class="hei_text titletext bold" v-if="orderInfo.status==7 && orderInfo.ps_type==2">騎手外送配送中
					</view>
					<view class="hei_text titletext bold" v-if="orderInfo.status==8&&orderInfo.ps_type==0">配送中</view>
					<view class="hei_text titletext bold"
						v-if="orderInfo.status==8&&(orderInfo.ps_type==1 || orderInfo.ps_type==2)">配送中</view>
					<view class="hei_text titletext bold" v-if="orderInfo.status==5">待出貨</view>
					<view class="hei_text titletext bold" v-if="orderInfo.status==87">待完成</view>
					<view class="hei_text titletext bold" v-if="orderInfo.status==88">已完成</view>
					<!-- <view class="hei_text titletext bold" v-if="orderInfo.status==5">备货中</view> -->
				</view>
				<view class="flexright">
					<view class="hong_text titletext bold"
						v-if="orderInfo.type==2&&orderInfo.desk && orderInfo.desk!=-1">{{orderInfo.desk}}
					</view>
					<view class="hong_text titletext margin_left bold">#{{orderInfo.call_no}}</view>
				</view>
			</view>
			<view class="mainpadding_top ffffff radius" v-if="orderInfo.user">
				<template>
					<view class="flexbetween" v-if="orderInfo.user.nickname || orderInfo.user.mobile">
						<view class="flexleft">
							<u-icon name="account" color="#ff8505" size="16"></u-icon>
							<view class="hei_text main_size margin_left2">{{orderInfo.user.nickname || ""}}
								<text class="margin_left2">{{maskMiddle(orderInfo.user.mobile)}}</text>
							</view>
							<view class="copyimg" @click="copy(orderInfo.user.mobile)"></view>
						</view>
						<view class="flexright beihuolable radius" v-if="orderInfo.user.mobile && orderInfo.status!=88"
							@click="phone(orderInfo.user.mobile)">
							<u-icon name="phone" color="#ff8505" size="18"></u-icon>
							<view class="xiaohuang">撥打電話</view>
						</view>
					</view>
				</template>
				<view class="flexleft margin_top">
					<u-icon name="clock" color="#ff8505" size="16"></u-icon>
					<view class="hei_text main_size margin_left2">{{http.timereturn(orderInfo.createtime * 1000)}}
					</view>
				</view>
				<view class="flexright">
					<view class="listbtnhuang margin_left2" @click="enterChat">聊聊</view>
				</view>
			</view>
			<view class="mainpadding_top ffffff radius">
				<view class="titletext hei_text bold">已點商品</view>
				<view class="pdl" v-for="item in orderInfo.goods_data" :key="item.id">
					<view class="flexleft margin_top">
						<view class="listleftimg radius margin_right">
							<image class="listleftimg radius" :src="item.logoimage" mode=""></image>
						</view>
						<view class="justify_between_column" style="height: 157rpx;width: 100%;">
							<view class="hei_text main_size bold">{{item.goods_name}}</view>
							<view class="xiaohui flexbetween" v-if="item.wei || item.hei">
								<text>尺寸：{{item.wei}}*{{item.hei}}</text>
								<text>用量：{{item.formulacount}}{{item.size}}</text>
							</view>
							<view class="xiaolan" v-if="item.spunatdata_text && item.spunatdata_text.length">規格：<text
									class="margin_right1" v-for="(value) in item.spunatdata_text"
									:key="value.spunatid">{{value.spunatname}}*{{value.num}}&nbsp;&nbsp;&nbsp;</text>
							</view>
							<view class="flexbetween">
								<view class="main_size huang_text bold">${{item.d_price}}&nbsp;&nbsp;&nbsp;x{{item.num}}
								</view>
								<view class="main_size huang_text bold">${{item.price}}</view>
							</view>
						</view>
					</view>
					<view class="flexright margin_top2" v-show="orderInfo.status==5">
						<view class="listbtnhuang" v-show="orderInfo.type==2&&item.is_sell==0"
							@click.stop="singleShipment(item,orderInfo)">出貨</view>
						<view class="listbtnhui" v-show="orderInfo.type==2&&item.is_sell==1">已出貨</view>
					</view>
					<view class="flexbetween margin_top" v-if="item.addimage">
						<view class="flexleft">
							<image src="../../static/image/system/wenjian.png" style="width: 56rpx;height: 56rpx;"
								mode="">
							</image>
							<view class="titletext hei_text bold margin_left">客戶文件</view>
						</view>
						<view class="flexright">
							<view class="listbtnhuang margin_left2" @click="downfile(item)">立即下載</view>
						</view>
					</view>
					<template v-if="item.sp_attr">
						<view class="flexbetween margin_top1" v-for="(ite,ind) in item.sp_attr_text" :key="ind">
							<view class="xiaohei smalltext">{{ite.name}}</view>
							<view class="xiaohui smalltext">{{ite.value}}</view>
						</view>
					</template>
				</view>
				<view class="pdl" v-for="item in cdbjhsf_data" :key="item.id" v-if="item.price!=0 && item.num!=0">
					<view class="flexleft margin_top">
						<view class="listleftimg radius margin_right">
							<image class="listleftimg radius" src="@/static/logo.png" mode=""></image>
						</view>
						<view class="justify_between_column" style="height: 157rpx;width: 100%;">
							<view class="hei_text main_size bold">{{item.name}}</view>
							<view class="flexbetween">
								<view class="main_size huang_text bold">${{item.price}}&nbsp;&nbsp;&nbsp;x{{item.num}}
								</view>
								<view class="main_size huang_text bold">${{item.price*item.num}}</view>
							</view>
						</view>
					</view>
				</view>
			</view>
			<view class="mainpadding_top ffffff radius" v-if="orderInfo.ordernotes">
				<view class="titletext hei_text bold">訂單備注</view>
				<view class="hui_text main_size margin_top word_wrap">{{orderInfo.ordernotes}}</view>
			</view>
			<view class="mainpadding_top ffffff radius" v-if="orderInfo.status==7">
				<view class="titletext hei_text bold">騎手信息</view>
				<view class="flexbetween margin_top">
					<view class="hei_text main_size">姓名</view>
					<view class="hui_text main_size">{{orderInfo.takeaway.name}}</view>
				</view>
				<view class="flexbetween margin_top">
					<view class="hei_text main_size">手機號</view>
					<view class="flexright">
						<view class="hui_text main_size">{{orderInfo.takeaway.phone}}</view>
						<view class="flexright beihuolable margin_left1 radius"
							@click="phone(orderInfo.takeaway.phone)">
							<u-icon name="phone" color="#ff8505" size="18"></u-icon>
							<view class="xiaohuang">撥打電話</view>
						</view>
					</view>
				</view>
			</view>
			<view class="mainpadding_top ffffff radius" v-if="orderInfo.opentype!==-1 && orderInfo.fpinfo!=null"
				@click="gofpDetail(orderInfo.fpinfo)">
				<view class="flexbetween">
					<view class="titletext hei_text bold">發票信息</view>
					<text class="weikai" v-if="orderInfo.fpinfo && orderInfo.fpinfo.is_ly==1">未列印</text>
					<text class="yikai" v-if="orderInfo.fpinfo && orderInfo.fpinfo.is_ly==2">已列印</text>
				</view>
				<view class="flexbetween bold margin_top">
					<view class="flexleft">
						<view class="xiaolan bold main_size lanlable" v-if="orderInfo.opentype==0">紙本</view>
						<view class="xiaolan bold main_size lanlable" v-if="orderInfo.opentype==1">載具</view>
						<view class="xiaolan bold main_size lanlable" v-if="orderInfo.opentype==2">統編</view>
						<view class="xiaolan bold main_size lanlable" v-if="orderInfo.opentype==3">捐贈</view>
						<view v-if="orderInfo.fpinfo && orderInfo.fpinfo.BuyerIdentifier!='0000000000' && orderInfo.opentype==2"
							class="bold xiaolan margin_left2 ershib">{{orderInfo.fpinfo.BuyerIdentifier}}</view>
						<view v-if="orderInfo.fpinfo && orderInfo.opentype==1" class="bold xiaolan margin_left2 titletext">
							{{orderInfo.fpinfo.BuyerName}}
						</view>
					</view>
					<view class="flexright"  v-if="orderInfo.fpinfo && orderInfo.fpinfo.invoice_number">
						<view class="bold main_size margin_right1" :class="orderInfo.fpinfo.status==3?'xiaohong':'xiaolan'">
							發票號碼：{{orderInfo.fpinfo.invoice_number}}</view>
						<view class="xiaohong bold main_size" v-if="orderInfo.fpinfo.status==3">作廢</view>
					</view>
				</view>
				<view class="flexbetween bold margin_top" v-if="orderInfo.opentype==2">
					<view class="xiaolan bold main_size" v-if="orderInfo.tbmc">發票抬頭 </view>
					<view class="xiaolan bold main_size" v-if="orderInfo.tbmc">{{orderInfo.tbmc}}</view>
				</view>
			</view>

			<view class="mainpadding_top ffffff line_b9"
				v-if="(orderInfo.opentype==-1 && appkey) || (orderInfo.fpinfo==null && appkey)">
				<view class="flexbetween">
					<view class="text_weight color_san white_nowrap">發票類型
					</view>
					<!-- <view class="listbtnhuang">開立發票</view> -->
					<view class="listbtnhuang" @click="kailifp">開立發票</view>
				</view>

				<view class="margin_top flexbetween">
					<view :class="opentype==0?'flexleft select':'flexleft noSelect'" @click="opentype=0">
						<image class="vote1Img"
							:src="opentype==0?'@/static/images/mine/vote1_active.png':'@/static/images/mine/vote1.png'"
							mode=""></image>
						<view>紙本</view>
					</view>
					<view :class="opentype==1?'flexleft select':'flexleft noSelect'" @click="opentype=1;">
						<image class="vote2Img"
							:src="opentype==1?'@/static/images/mine/vote2_active.png':'@/static/images/mine/vote2.png'"
							mode=""></image>
						<view>載具</view>
					</view>
					<view :class="opentype==2?'flexleft select':'flexleft noSelect'"
						@click="opentype=2;">
						<image class="vote3Img"
							:src="opentype==2?'@/static/images/mine/vote3_active.png':'@/static/images/mine/vote3.png'"
							mode=""></image>
						<view>統編</view>
					</view>
					<view :class="opentype==3?'flexleft select':'flexleft noSelect'" @click="opentype=3;">
						<image class="vote4Img"
							:src="opentype==3?'@/static/images/mine/vote4_active.png':'@/static/images/mine/vote4.png'"
							mode=""></image>
						<view>捐贈</view>
					</view>
				</view>
				<view class="invoiceInput margin_top flexbetween" v-show="opentype!=0">
					<input class="text_b" type="text" placeholder="請輸入手機載具" v-show="opentype==1" v-model="tbcode">
					<input class="text_b" type="text" placeholder="請輸入統一編碼" @blur="getTt()" v-show="opentype==2"
						v-model="tbcode">
					<input class="text_b" type="text" placeholder="請輸入捐贈碼" v-show="opentype==3" v-model="tbcode">
					<view class="" v-show="opentype==1 || opentype==3" @click="getCode()">
						<u-icon name="scan" color="#ffb800" size="28"></u-icon>
					</view>
				</view>
				<view class="invoiceInput margin_top" v-show="opentype==2">
					<input class="text_b" type="text" placeholder="請輸入發票抬頭" v-model="tbmc">
				</view>
			</view>
			<view class="mainpadding_top ffffff radius">
				<view class="flexbetween">
					<view class="hei_text main_size bold">訂單合計</view>
					<view class="hui_text main_size bold">${{Number(orderInfo.total_goods_price)}}</view>
				</view>
				<view class="flexbetween margin_top1">
					<view class="hei_text main_size bold">配送費</view>
					<view class="hui_text main_size bold">${{orderInfo.freight_price || 0}}</view>
				</view>
				<view class="flexbetween margin_top1">
					<view class="hei_text main_size bold">服務費</view>
					<view class="hui_text main_size bold">${{orderInfo.fw_price || 0}}</view>
				</view>
				<view class="flexbetween margin_top1" v-if="orderInfo.type==2">
					<view class="hei_text main_size bold">低消抵扣</view>
					<view class="huang_text main_size bold">-${{orderInfo.table_price || 0}}</view>
				</view>
				<view class="flexbetween margin_top1">
					<view class="hei_text main_size bold">優惠金額</view>
					<view class="huang_text main_size bold">-${{orderInfo.yh_money || 0}}</view>
				</view>
				<view class="flexbetween margin_top1">
					<view class="hei_text main_size bold">儲值點數</view>
					<view class="huang_text main_size bold">-${{orderInfo.shop_user_price || 0}}</view>
				</view>
				<view v-show="orderInfo.paytype!=0">
					<view class="flexbetween margin_top1">
						<view class="hei_text main_size bold">{{returnzftext(orderInfo.paytype)}}</view>
						<view class="huang_text main_size bold">-${{orderInfo.paymoney}}</view>
					</view>
				</view>
				<view class="flexbetween margin_top1 dashedline">
					<view class="hei_text main_size bold">總金額</view>
					<view class="huang_text main_size bold">${{orderInfo.countmoney || 0}}</view>
				</view>

				<view class="flexbetween margin_top1">
					<view class="hei_text main_size bold">已付金額</view>
					<view class="huang_text main_size bold">${{Number(orderInfo.paymoney)+Number(orderInfo.shop_user_price)|| 0}}</view>
				</view>
				<view class="flexbetween margin_top1">
					<view class="hei_text main_size bold">未付金額</view>
					<view class="hong_text main_size bold">${{orderInfo.zhuimoney || 0}}</view>
				</view>
				<view class="flexbetween margin_top1">
					<view class="hei_text main_size bold">訂單編號</view>
					<view class="hui_text main_size bold">{{orderInfo.order_sn}}</view>
				</view>
				<view class="flexbetween margin_top1" v-if="orderInfo.createtime">
					<view class="hei_text main_size bold">下單時間</view>
					<view class="hui_text main_size bold">{{secondDate(orderInfo.createtime,0,0)}}</view>
				</view>
				<view class="flexbetween margin_top1" v-if="orderInfo.jdtime">
					<view class="hei_text main_size bold">接單時間</view>
					<view class="hui_text main_size bold">{{http.timereturn(orderInfo.jdtime * 1000)}}</view>
				</view>
				<view v-show="orderInfo.paytype!=0">
					<view class="flexbetween margin_top1">
						<view class="hei_text main_size bold">支付方式</view>
						<view class="hui_text main_size bold" v-if="orderInfo.paytype==1 && orderInfo.status!=0">點數支付
						</view>
						<view class="hui_text main_size bold" v-if="orderInfo.paytype==2">多元支付</view>
						<view class="hui_text main_size bold" v-if="orderInfo.paytype==3">現金支付</view>
						<view class="hui_text main_size bold" v-if="orderInfo.paytype==4">信用卡</view>
						<view class="hui_text main_size bold" v-if="orderInfo.paytype==5">Line Pay線上支付
						</view>
						<view class="hui_text main_size bold" v-if="orderInfo.paytype==6">街口線上支付
						</view>
						<view class="hui_text main_size bold" v-if="orderInfo.paytype==7">街口線下支付
						</view>
						<view class="hui_text main_size bold" v-if="orderInfo.paytype==8">Line Pay線下支付
						</view>
						<view class="hui_text main_size bold" v-show="orderInfo.paytype==9">Line Pay二維碼支付
						</view>
						<view class="hui_text main_size bold" v-show="orderInfo.paytype==10">街口二維碼支付
						</view>
						<view class="hui_text main_size bold" v-show="orderInfo.paytype==11">全支付線下支付
						</view>
					</view>
				</view>
				<template v-if="orderInfo.paytype==6 || orderInfo.paytype==7">
					<view class="flexbetween margin_top1">
						<view class="hei_text main_size bold">街口券折抵 </view>
						<view class="hui_text main_size bold">${{orderInfo.RedeemAmount}}</view>
					</view>
					<view class="flexbetween margin_top1">
						<view class="hei_text main_size bold">街口幣折抵 </view>
						<view class="hui_text main_size bold">${{orderInfo.StoreRedeemAmount}}</view>
					</view>
				</template>
				<template v-if="orderInfo.paytype==5 || orderInfo.paytype==8">
					<view class="flexbetween margin_top1">
						<view class="hei_text main_size bold">LINE POINTS折抵 </view>
						<view class="hui_text main_size bold">${{orderInfo.RedeemAmount}}</view>
					</view>
					<view class="flexbetween margin_top1">
						<view class="hei_text main_size bold">LINE 優惠券折抵 </view>
						<view class="hui_text main_size bold">${{orderInfo.StoreRedeemAmount}}</view>
					</view>
				</template>
				<view class="flexbetween margin_top1" v-if="orderInfo.type==2">
					<view class="hei_text main_size bold">用餐人數</view>
					<view class="hui_text main_size bold" v-if="!orderInfo.cdbjhsf_data">
						老人：{{orderInfo.old}}，客戶：{{orderInfo.adult}}，兒童：{{orderInfo.child}}，共{{Number(orderInfo.old)+Number(orderInfo.adult)+Number(orderInfo.child)}}人
					</view>
					<!-- order_type订單类型:1=普通订單,2=预约订單,3=吃到饱订單,4=pos点餐,5=加总点單、 -->
					<view class="hui_text main_size bold" v-if="orderInfo.cdbjhsf_data">
						<text v-for="(item,index) in cdbjhsf_data" :key="index">
							<text v-if="item.num!=0"><text class="huang_text">{{item.num}}</text>/{{item.name}}</text>
						</text>
					</view>
				</view>
				<view class="flexbetween margin_top1" v-if="orderInfo.order_type==3">
					<view class="hei_text main_size bold">人數基本價</view>
					<view class="huang_text main_size bold">${{orderInfo.rs_price}}</view>
				</view>
				<view class="flexbetween margin_top1" v-if="orderInfo.order_type==3">
					<view class="hei_text main_size bold">商品總金額</view>
					<view class="huang_text main_size bold">
						${{Number(orderInfo.countmoney)-Number(orderInfo.rs_price)-Number(orderInfo.fw_price)}}</view>
				</view>

				<view class="flexbetween margin_top1" v-if="orderInfo.paypz_image_text">
					<view class="xiaohei main_size">支付憑證</view>
					<image class="listleftimg1 radius" :src="orderInfo.paypz_image_text" mode=""
						@click.stop="lbtpriview(0,[orderInfo.paypz_image_text])"></image>
				</view>
				<view class="flexbetween margin_top1" v-if="orderInfo.pzqh_image_text">
					<view class="hei_text main_size bold">騎手取貨上傳</view>
					<view class="hui_text main_size bold">{{http.timereturn(orderInfo.qhtime * 1000)}}</view>
				</view>
				<view class="flexleft" v-if="orderInfo.pzqh_image_text">
					<view class="itemimgBox flexcenter margin_top1" v-for="(item,index) in orderInfo.pzqh_image_text"
						:key="index">
						<image class="listleftimg radius" :src="item" mode=""
							@click="lbtpriview(index,orderInfo.pzqh_image_text)"></image>
					</view>
				</view>
				<view class="flexbetween margin_top1" v-if="orderInfo.pzsd_image_text">
					<view class="hei_text main_size bold">騎手送達上傳</view>
					<view class="hui_text main_size bold">{{http.timereturn(orderInfo.endtime * 1000)}}</view>
				</view>
				<view class="flexleft" v-if="orderInfo.pzsd_image_text">
					<view class="itemimgBox flexcenter margin_top1" v-for="(item,index) in orderInfo.pzsd_image_text"
						:key="index">
						<image class="listleftimg radius" :src="item" mode=""
							@click="lbtpriview(index,orderInfo.pzsd_image_text)"></image>
					</view>
				</view>
			</view>

			<view class="mainpadding_top ffffff radius" @click="toOrderlog(orderInfo.id)">
				<view class="flexbetween">
					<view class="hei_text main_size bold">訂單操作日誌</view>
					<u-icon name="arrow-right" color="#999999"></u-icon>
				</view>
			</view>


		</view>
		<view class="posibottom mainpadding flexright ffffff">
			<!-- <view class="listbtnhui" v-show="orderInfo.status==0||orderInfo.status==1||orderInfo.status==7"
				@click.stop="phone(orderInfo.mobile)">聯係客戶</view> -->

			<view class="listbtnhui margin_left2" v-show="orderInfo.status==0" @click.stop="cancelorder(orderInfo)">取消訂單
			</view>
			<view class="listbtnhuang margin_left2" v-show="orderInfo.status==1" @click="suretakOrder(orderInfo)">確認接單
			</view>
			<!-- 多元支付都有確認收款按钮 -->
			<view class="listbtnhuang margin_left2" @click.stop="xianjinwfsk(orderInfo)" v-show="orderInfo.status==0">
				確認收款
			</view>
			<view class="listbtnhui margin_left2" v-show="orderInfo.status==2" @click.stop="aginDyOrder(orderInfo.id)">
				收據列印
			</view>
			<view class="listbtnhui margin_left2" v-show="orderInfo.status==2" @click.stop="workprint(orderInfo.id)">
				工作站列印
			</view>
			<view class="listbtnhuang margin_left2" v-show="orderInfo.type==2&&orderInfo.status==5"
				@click="allShipment(orderInfo)">一次出貨</view>
			<view class="listbtnhuang margin_left2" v-show="orderInfo.type==1&&orderInfo.status==5"
				@click="takeGoods(orderInfo.id,orderInfo.user_id)">通知提貨</view>
			<view class="listbtnhuang" @click="wuliupsFn(orderInfo.id)" v-show="orderInfo.type==0&&orderInfo.status==5">
				物流配送</view>
			<view class="listbtnhuang margin_left2" @click="phone(orderInfo.takeaway.phone)"
				v-show="(orderInfo.status==7&&orderInfo.ps_type==1)||(orderInfo.status==7&&orderInfo.ps_type==2)">聯係騎手
			</view>
			<view class="listbtnhuang margin_left2" @click="chakanwlFn()"
				v-show="orderInfo.status==8&&orderInfo.ps_type==0">查看物流
			</view>
			<view class="listbtnhuang margin_left2"
				v-show="orderInfo.type==2 && (orderInfo.status==2 || orderInfo.status==5 || orderInfo.status==87) && orderInfo.order_type!=3"
				@click.stop="diancan(orderInfo)">點餐
			</view>
			<view class="listbtnhui margin_left2" v-show="orderInfo.type==0&&orderInfo.status==5"
				@click="qsws(orderInfo.id)">騎手外送</view>
			<view class="listbtnhuang margin_left2" @click="shopDeliver(orderInfo.id)"
				v-show="orderInfo.type==0&&orderInfo.status==5">商家自送</view>
			<view class="listbtnhuang margin_left2"
				v-show="(orderInfo.status==87 || orderInfo.status==88) && (Number(orderInfo.zhuimoney)!=0) && orderInfo.order_type!=2 && orderInfo.order_type!=3"
				@click.stop="xianjinsk(orderInfo)">確認收款</view>
			<view class="listbtnhuang margin_left2" v-show="orderInfo.type==1&&orderInfo.status==87"
				@click="tongzhith(orderInfo.id,orderInfo.user_id)">通知提貨</view>
			<view class="listbtnhuang margin_left2" v-show="orderInfo.status==87 && orderInfo.zhuimoney==0"
				@click.stop="wanchengfw(orderInfo)">完成服務</view>
			<!-- <view class="listbtnhui margin_left2" v-show="orderInfo.status==88">开具发票</view> -->
			<!-- <view class="listbtnhuang margin_left2" v-show="orderInfo.status==88">查看评价</view> -->
		</view>
		<!-- 物流配送 -->
		<u-modal :show="wlpsModal.show" title="物流配送" confirmColor="#FF8505" :closeOnClickOverlay="true" confirmText="確認"
			cancelText="取消" @close="wlpsModal.show=false" @confirm="wlpsconfirm">
			<view class="slot-content flexcenter mainpadding_top">
				<input type="text" placeholder="請輸入物流單號" style="text-align: center;" v-model="wlpsModal.text">
			</view>
		</u-modal>
		<!-- 查看物流 -->
		<u-modal :show="ckwlModal.show" title="查看物流" confirmColor="#FF8505" confirmText="點擊複製"
			:closeOnClickOverlay="true" @close="ckwlModal.show=false" @confirm="copy(ckwlModal.text)">
			<view class="slot-content flexcenter mainpadding_top">{{ckwlModal.text}}</view>
		</u-modal>
	</view>
</template>

<script>
	const httpRequest = require("@/common/httpRequest.js")
	export default {
		data() {
			return {
				wlpsModal: { //物流配送
					show: false,
					text: "",
				},
				ckwlModal: { //查看物流
					show: false,
					text: "",
				},
				orderInfo: "",
				pageShow: false,
				id: "", //物流配送的订單id
				ztNum: 0,
				cdbjhsf_data: [],

				opentype: 0, //開票類型 0紙本 1載具 2統編 3捐贈
				tbcode: "", //開票内容
				tbcode1: "",
				jzcode: "",
				zjcode: "",
				tbmc: "",
				appkey: "",
			}
		},
		watch: {
			"wlpsModal.show"(newval) {
				if (!newval) {
					this.wlpsModal.text = ""
				}
			},
			opentype(newval){
				if(this.opentype==0)this.tbcode = ""
				if(this.opentype==1)this.tbcode = this.zjcode
				if(this.opentype==2)this.tbcode = this.tbcode1
				if(this.opentype==3)this.tbcode = this.jzcode
			}
		},
		onLoad(options) {
			this.appkey = uni.getStorageSync("appkey")
			uni.$on("returnCode", data => {
				this.tbcode = data
			})
			this.id = options.id
			this.getInfo()
			this.getztnum()
		},
		onUnload() {
			uni.$off("returnCode")
		},
		methods: {
			gofpDetail(fpInfo) {
				if (fpInfo.id) {
					uni.navigateTo({
						url: "/pages/workbench/invoiceDetail?id=" + fpInfo.id
					})
				}
			},
			// 开立发票
			kailifp() {
				if (this.opentype == 2 && this.tbcode.length != 8) {
					httpRequest.toast("請輸入正確統編")
					return false
				}
				if (this.opentype == 2 && this.tbmc == "") {
					return false
				}
				httpRequest.request('/api/ordergoods/ordergoodsKjFp', 'GET', {
					opentype: this.opentype,
					tbcode: this.tbcode,
					tbmc: this.tbmc,
					id: this.id
				}).then(res => {
					httpRequest.toast(res.msg)
					if (res.code == 1) {
						this.getInfo()
					}
				})
			},
			getTt() {
				if (this.opentype != 2) {
					return false
				}
				this.http.request("/api/user/getTbmc", "GET", {
					tbcode: this.tbcode
				}).then(res => {
					if (res.code == 1) {
						this.tbmc = res.data.tbinfo.name
					}
				})
			},
			toOrderlog(id) {
				uni.navigateTo({
					url: "/pages/goodsOrder/orderlog?id=" + id
				})
			},
			getCode() {
				uni.navigateTo({
					url: "/pages/my/getcodetwm"
				})
			},
			diancan(item) {
				uni.setStorageSync("order_goods_id", item.id)
				uni.navigateTo({
					url: "/pages/callOutOrder/xuanzefw?orderly=1"
				})
			},
			enterChat() {
				if (this.orderInfo.user.id == uni.getStorageSync('user_id')) {
					httpRequest.toast("自己不能和自己聊天哦！");
					return false
				}
				let that = this
				uni.showLoading({
					mask: true,
					title: "請稍後"
				})
				httpRequest.requestChat('/api/user/addFriends', 'GET', {
					firend_id: this.orderInfo.user.id,
					sendtype: 1,
					user_id: uni.getStorageSync('user_id')
				}).then(res => {
					uni.hideLoading()
					let data = {
						firend_id: this.orderInfo.user.id,
						friend_name: this.orderInfo.user.nickname,
						firend_avatar_text: this.orderInfo.user.avatar_text
					}
					uni.navigateTo({
						url: "/pages/message/chat?msg=" + encodeURIComponent(JSON.stringify(data))
					})
				})
			},
			async getztnum() { //使用列表
				let res = await this.http.request('/api/shop/listtable', 'POST', {
					shop_id: uni.getStorageSync("shop_id"), //店鋪id
				})
				if (res.code == 1) {
					this.ztNum = res.data.length
				} else {
					this.ztNum = 0
				}
			},
			xianjinwfsk(item) {
				this.http.modal('', '請確認是否完成確認收款', true, (res) => {
					if (res) {
						this.http.request('/api/pay/quredypay', 'POST', {
							id: item.id,
						}).then(res => {
							if (res.code == 1) {
								this.http.toast("確認收款完成")
								this.getInfo()
							} else {
								this.http.toast(res.msg)
							}
						})
					}
				})
			},
			cancelorder(item) {
				this.http.modal('', '請確認是否取消當前訂單', true, (res) => {
					if (res) {
						this.http.request('/api/ordergoods/cancelOrder', 'GET', {
							id: item.id,
						}).then(res => {
							this.http.toast(res.msg)
							if (res.code == 1) {
								this.getInfo()
							}
						})
					}
				})
			},
			wanchengfw(item) {
				this.http.modal('', '是否確認完成服務', true, (res) => {
					if (res) {
						this.http.request('/api/ordergoods/neiendgoods', 'POST', {
							id: item.id,
						}).then(res => {
							if (res.code == 1) {
								this.http.toast("已完成服務")
								this.getInfo()
							} else {
								this.http.toast(res.msg)
							}
						})
					}
				})
			},
			lbtpriview(index, arr) {
				var i = arr; //获取当前页面的轮播图数据
				//uniapp预览轮播图
				uni.previewImage({
					current: index, //预览图片的下标
					urls: i //预览图片的地址，必須要数组形式，如果不是数组形式就转换成数组形式就可以
				})
			},
			xianjinsk(item) {
				if (item.order_type == 1) {
					uni.navigateTo({
						url: "/pages/goodsOrder/goodssk?total_price=" + item.zhuimoney + "&id=" + item.id
					})
				} else {
					uni.navigateTo({
						url: "/pages/yuYueOrder/yuyuesk?total_price=" + item.zhuimoney + "&id=" + item.ordermak_id
					})
				}

			},
			// 下载文件
			downfile(item) {
				var that = this
				//加载框动画
				uni.showLoading({
					title: '正在下載……'
				});
				uni.downloadFile({
					url: this.imgUrlUser + item.addimage, //下载地址接口返回
					success: (data) => {
						if (data.statusCode === 200) {
							//隐藏加载框
							uni.hideLoading();
							//文件保存到本地
							// #ifdef H5
							const a = document.createElement('a');
							a.href = data.tempFilePath; //filePath 这里的地址是 uni.downloadFile 中的返回值里的地址
							a.download = ""; // 可以设置下载文件名，如果是空字符串，则使用服务器端设置的文件名
							a.click();
							// #endif
							// #ifdef MP-WEIXIN
							uni.saveFile({
								tempFilePath: data.tempFilePath, //临时路径
								success: function(res) {
									uni.showToast({
										icon: 'success',
										mask: true,
										// title: '文件已保存：' + res.savedFilePath, //保存路径
										title: '下載成功',
										duration: 2000,
									});
									//自动打开文档查看
									setTimeout(() => {
										var filePath = res.savedFilePath;
										uni.openDocument({ //新开页面打开文档，支持格式：doc, xls, ppt, pdf, docx, xlsx, pptx。
											filePath: filePath,
											showMenu: true,
											success: function(res) {}
										});
									}, 2000)
								}
							});
							// #endif
						}
					},
					fail: (err) => {
						console.log(err);
						uni.showToast({
							icon: 'none',
							mask: true,
							title: '文件下載失敗',
						});
					},
				});
			},
			async getInfo() { //订單详情
				let res = await this.http.request('/api/Ordergoods/deailOrdergoods', 'POST', {
					id: this.id
				})
				if (res.code == 1) {
					let goods_allprice = 0
					res.data.goods_data.forEach(value => {
						value.logoimage = this.imgUrlUser + value.logoimage
						goods_allprice = Number(value.price) + Number(goods_allprice)
					})
					this.$set(res.data, "goods_allprice", goods_allprice)
					if (res.data.pzqh_image) {
						let pzqh_image_text1 = res.data.pzqh_image.split(",")
						let pzqh_image_text = []
						if (pzqh_image_text1.length) {
							pzqh_image_text1.forEach(item => {
								let text = this.imgUrlUser + item
								pzqh_image_text.push(text)
							})
							this.$set(res.data, "pzqh_image_text", pzqh_image_text)
							console.log(res.data);
						}
					}

					if (res.data.pzsd_image) {
						let pzsd_image_text1 = res.data.pzsd_image.split(",")
						let pzsd_image_text = []
						if (pzsd_image_text1.length) {
							pzsd_image_text1.forEach(item => {
								let text = this.imgUrlUser + item
								pzsd_image_text.push(text)
							})
							this.$set(res.data, "pzsd_image_text", pzsd_image_text)
						}
					}
					this.orderInfo = res.data
					if (res.data.cdbjhsf_data) {
						this.cdbjhsf_data = JSON.parse(res.data.cdbjhsf_data)
					}
					if (this.orderInfo.opentype == -1 && res.data.user) {
						let fpinfo = res.data.user
						if (fpinfo.opentype != 0) {
							this.opentype = fpinfo.opentype
						}
						if (fpinfo.jzcode) {
							this.jzcode = fpinfo.jzcode
							this.tbcode = fpinfo.jzcode
						}
						if (fpinfo.tbcode) {
							this.tbcode = fpinfo.tbcode
							this.tbcode1 = fpinfo.tbcode
						}
						if (fpinfo.zjcode) {
							this.zjcode = fpinfo.zjcode
							this.tbcode = fpinfo.zjcode
						}
						this.tbmc = fpinfo.tbmc
					}
					this.pageShow = true
				} else if (res.code == 0) {
					this.http.toast(res.msg)
				} else {
					this.http.toast('系統處理中，請稍後再試');
				}
			},
			// 重新打印小票
			async aginDyOrder(id) {
				uni.showLoading({
					mask: true,
					title: "請稍後"
				})
				let res = await this.http.request('/api/ordergoods/aginDyOrder', 'POST', {
					id
				})
				uni.hideLoading()
				if (res.code == 1) {
					httpRequest.toast("已發送指令")
				} else {
					httpRequest.toast(res.msg)
				}
			},
			async workprint(id) {
				uni.showLoading({
					mask: true,
					title: "請稍後"
				})
				let res = await this.http.request('/api/ordergoods/workDy', 'POST', {
					id
				})
				uni.hideLoading()
				httpRequest.toast(res.msg)
			},
			async suretakOrder(item) { // 確認接單
				if (item.type == 2 && this.ztNum != 0 && Number(item.desk) <= 0) {
					let count = Number(item.adult) + Number(item.old) + Number(item.child)
					uni.navigateTo({
						url: `/pages/goodsOrder/xuanzezt?order_goods_id=${item.id}&count=${count}`
					})
					return false
				}
				let res = await this.http.request('/api/Ordergoods/jieOrdergoods', 'POST', {
					id: item.id,
				})
				if (res.code == 1) {
					this.http.toast("接單成功")
					setTimeout(() => {
						uni.navigateBack(1)
					})
				} else if (res.code == 0) {
					this.http.toast(res.msg)
				} else {
					this.http.toast('系統處理中，請稍後再試');
				}
			},
			async singleShipment(value, item) { //單個出货
				let res = await this.http.request('/api/Ordergoods/shellgoods_n', 'POST', {
					id: value.id,
					order_goods_id: item.id
				})
				if (res.code == 1) {
					this.http.toast("出貨成功")
					this.getInfo()
				} else if (res.code == 0) {
					this.http.toast(res.msg)
				} else {
					this.http.toast('系統處理中，請稍後再試');
				}
			},
			async allShipment(item) { //一次出货
				let res = await this.http.request('/api/Ordergoods/allgoods_n', 'POST', {
					id: item.id
				})
				if (res.code == 1) {
					this.http.toast("出貨成功")
					setTimeout(() => {
						uni.navigateBack(1)
					})
				} else if (res.code == 0) {
					this.http.toast(res.msg)
				} else {
					this.http.toast('系統處理中，請稍後再試');
				}
			},
			async takeGoods(id,user_id) { //確認提货
				this.tongzhith(id, user_id)
				let res = await this.http.request('/api/Ordergoods/endgoods', 'POST', {
					id
				})
				if (res.code == 1) {
					this.http.toast("提貨成功")
					setTimeout(() => {
						uni.navigateBack(1)
					})
				} else if (res.code == 0) {
					this.http.toast(res.msg)
				} else {
					this.http.toast('系統處理中，請稍後再試');
				}
			},
			async tongzhith(order_id, user_id) {
				let res = await this.http.request('/api/ordergoods/userGetFoods', 'POST', {
					order_id,
					user_id
				})
			},
			// 制作详情
			beihuodetail() {
				uni.navigateTo({
					url: "/pages/goodsOrder/beihuoxq"
				})
			},
			// 物流配送
			wuliupsFn(id) {
				this.id = id
				this.wlpsModal.show = true
			},
			async wlpsconfirm() {
				let res = await this.http.request('/api/Ordergoods/wlendgoods', 'POST', {
					id: this.id,
					shopfreight_num: this.wlpsModal.text
				})
				if (res.code == 1) {
					this.http.toast("送貨成功")
					setTimeout(() => {
						uni.navigateBack(1)
					}, 500)
				} else if (res.code == 0) {
					this.http.toast(res.msg)
				} else {
					this.http.toast('系統處理中，請稍後再試');
				}
				this.wlpsModal.show = false
			},
			// 查看物流
			chakanwlFn() {
				this.ckwlModal.show = true
				this.ckwlModal.text = this.orderInfo.shopfreight_num
			},
			async shopDeliver(id) { //商家自送
				let res = await this.http.request('/api/Ordergoods/shopendgoods', 'POST', {
					id
				})
				if (res.code == 1) {
					this.http.toast("送貨货成功")
					setTimeout(() => {
						uni.navigateBack(1)
					}, 500)
				} else if (res.code == 0) {
					this.http.toast(res.msg)
				} else {
					this.http.toast('系統處理中，請稍後再試');
				}
			},
			async qsws(id) { //骑手外送
				let res = await this.http.request('/api/Ordergoods/qsendgoods', 'POST', {
					id
				})
				if (res.code == 1) {
					this.http.toast("送貨成功")
					setTimeout(() => {
						uni.navigateBack(1)
					}, 500)
				} else if (res.code == 0) {
					this.http.toast(res.msg)
				} else {
					this.http.toast('系統處理中，請稍後再試');
				}
			},
			copy(value) {
				this.ckwlModal.show = false
				uni.setClipboardData({
					data: value.toString(), //要被复制的内容
					success: () => {
						//复制成功的回调函数
						this.http.toast("複製成功")
					}
				});
			}
		}
	}
</script>

<style lang="scss" scoped>
	.weikai {
		border-radius: 0 10rpx 0 10rpx;
		background-color: rgba(153, 153, 153, .1);
		font-size: 28rpx;
		font-family: PingFang SC-Medium, PingFang SC;
		font-weight: 500;
		color: #999;
		padding: 5rpx 30rpx;
	}

	.yikai {
		border-radius: 0 10rpx 0 10rpx;
		background-color: #50a6a3;
		font-size: 28rpx;
		font-family: PingFang SC-Medium, PingFang SC;
		font-weight: 500;
		color: #fff;
		padding: 5rpx 30rpx;
	}

	.listleftimg1 {
		width: 150rpx;
		min-width: 150rpx;
		height: 150rpx;
		position: relative;

		image {
			width: 100%;
			height: 100%;
		}
	}

	.beihuolable {
		background-color: #fff3e6;
		padding: 5rpx 10rpx;
		border: 1rpx solid #FF8505;
	}

	.posibottom {
		position: fixed;
		bottom: 0;
		left: 0;
		width: 100%;
		box-sizing: border-box;
	}



	.vote1Img {
		width: 26rpx;
		height: 26rpx;
		margin-left: 20rpx;
		margin-right: 10rpx;
	}

	.vote2Img {
		width: 23.5rpx;
		height: 23.5rpx;
		margin-left: 20rpx;
		margin-right: 10rpx;
	}

	.vote3Img {
		width: 29rpx;
		height: 29rpx;
		margin-left: 20rpx;
		margin-right: 10rpx;
	}

	.vote4Img {
		width: 27rpx;
		height: 27rpx;
		margin-left: 20rpx;
		margin-right: 10rpx;
	}

	.noSelect {
		width: 154rpx;
		height: 69rpx;
		text-align: center;
		line-height: 69rpx;
		background: rgba(102, 102, 102, .1);
		border-radius: 8rpx 8rpx 8rpx 8rpx;
		border: 2rpx solid rgba(102, 102, 102, .1);
		font-size: 24rpx;
		font-family: PingFang SC-Medium, PingFang SC;
		font-weight: 500;
		color: #666666;
	}

	.select {
		width: 154rpx;
		height: 69rpx;
		text-align: center;
		line-height: 69rpx;
		background: rgba(255, 133, 5, 0.1);
		border-radius: 8rpx 8rpx 8rpx 8rpx;
		border: 2rpx solid #FF8505;
		font-size: 24rpx;
		font-family: PingFang SC-Medium, PingFang SC;
		font-weight: 500;
		color: #FF8505;
		position: relative;
	}

	.select::after {
		content: '';
		width: 25rpx;
		height: 20rpx;
		position: absolute;
		right: 0;
		bottom: 0;
		background-image: url('/static/images/mine/invoice_select.png');
		background-size: 100% 100%;
	}

	.invoiceInput {
		width: 100%;
		height: 91rpx;
		background: rgba(196, 196, 196, .1);
		border-radius: 8rpx 8rpx 8rpx 8rpx;
		display: flex;
		align-items: center;
		padding-left: 20rpx;

		input {
			width: 80%;
		}
	}
</style>